<template>
  <div class="create-or-edit">
    <el-form>
      <el-form-item>
        <el-select v-model="section.status">
          <el-option label="已隐藏" :value="0"></el-option>
          <el-option label="待更新" :value="1"></el-option>
          <el-option label="已发布" :value="2"></el-option> </el-select
      ></el-form-item>
      <el-form-item>
        <el-button @click="onCancel">取消</el-button>
        <el-button type="primary" @click="onSubmit">确认</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { saveOrUpdate } from "@/services/course-section";
export default {
  props: {
    chapter: {
      type: String,
    },
    section: {
      type: Object,
    },
  },
  methods: {
    onCancel() {
      // 设置取消状态，让父组件处理
      this.$emit("cancel");
    },
    async onSubmit() {
      const { data } = await saveOrUpdate(this.section);
      console.log(data);
      this.$emit("success");
      this.$message.success("添加成功");
    },
  },
};
</script>

<style lang="scss" scoped></style>
